package com.pubinfo.passbook.common.model.bo.bank;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pubinfo.passbook.common.entity.TBankId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@Data
@NoArgsConstructor
public class BankApplyReceipt implements Serializable
{
    @ApiModelProperty("开始时间（日对账单格式：yyyy-MM-dd,月对账单格式：yyyy-MM）")
    private String startDate;

    @ApiModelProperty("截止时间（日对账单格式：yyyy-MM-dd,月对账单格式：yyyy-MM）")
    private String endDate;

    @ApiModelProperty("单据类型(0-银行回单 1银行对账单)")
    private String type;

    @ApiModelProperty("对账单类型(0-日对账单,1-月对账单)")
    private String dzType;

    @ApiModelProperty("银行账户")
    private String cardNo;

    @ApiModelProperty("银行标识，为银行英文简称，如工商银行为：ICBC")
    private String platformId;

    public BankApplyReceipt(String Date, String type, String dzType, String cardNo, String platformId) {
        this.startDate = Date;
        this.endDate = Date;
        this.type = type;
        this.dzType = dzType;
        this.cardNo = cardNo;
        this.platformId = platformId;
    }

    public BankApplyReceipt(TBankId tBankId,String type,String dzType)
    {
        this.cardNo=tBankId.getBankId();
        this.platformId=tBankId.getPlatformId();
        SimpleDateFormat sdf=null;
        Calendar calendar=null;
        if(!type.equals("1") && !dzType.equals("1"))
        {
            sdf = new SimpleDateFormat("yyyy-MM-dd");
            calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -1);
        }
        else
        {
            sdf = new SimpleDateFormat("yyyy-MM");
            calendar = Calendar.getInstance();
            calendar.add(Calendar.MONTH, -1);
        }
        this.startDate= sdf.format(calendar.getTime());
        this.endDate= sdf.format(calendar.getTime());
        this.type=type;
        this.dzType=dzType;
    }
}
